package com.android.monee.data.model;

import java.util.Date;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.android.monee.data.access.IdNClone;

public class Mensuality implements IdNClone<Integer, Mensuality>, Comparable<Mensuality>{

	public enum MensualityState {
		DONE, UNDONE, CANCELLED
	};

	private Integer id;
	private Integer budgetId;
	private int number;
	private float amount;
	private Date date;
	private MensualityState state;

	public Mensuality(Mensuality mensuality) {
		this.id = mensuality.getId();
		this.budgetId = mensuality.getBudgetId();
		this.number = mensuality.getNumber();
		this.amount = mensuality.getAmount();
		this.date = mensuality.getDate();
		this.state = mensuality.getState();
	}

	public Mensuality() {
		this.state = MensualityState.UNDONE;
	}

	@Override
	public Mensuality clone() {
		Mensuality clone = null;
		try {
			clone = (Mensuality) super.clone();
			if(this.date != null)
				clone.date = (Date) this.date.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return clone;
	}

	@Override
	public boolean equals(Object o){
		return EqualsBuilder.reflectionEquals(this, o);
	}
	
	@Override
	public int hashCode(){
		return HashCodeBuilder.reflectionHashCode(this);
	}
	
	@Override
	public int compareTo(Mensuality another) {
		return this.date.compareTo(another.getDate());
	}
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getBudgetId() {
		return budgetId;
	}

	public void setBudgetId(Integer budgetId) {
		this.budgetId = budgetId;
	}

	public float getAmount() {
		return amount;
	}

	public void setAmount(float amount) {
		this.amount = amount;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public MensualityState getState() {
		return state;
	}

	public void setState(MensualityState state) {
		this.state = state;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}
}
